/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#include "ImageFileReader.hpp"
#include "owndebug.h"
int main(void){
  CImageFileReader reader;
  // Init Debug lib
  debugInit();
  debugSetGlobalDebugLvl(1);

  //  reader.ReadFile("../../../staticdata/datasets/Avant635/08_12_2010/Avant635.MaCI_Image.Firewire_08_12_2010_11:25:13.txt");
  reader.ReadFile("../../../staticdata/datasets/J2B2/08_02_11/KinectDataSet/KinectDevice.MaCI_Image.CameraData_08_02_2011_17:56:51.txt");


  std::string group,instance;
  if(reader.GetServiceInformation(group,instance)){
    dPrint(1,"Got service information. Group: %s, instance:%s",
           group.c_str(),
           instance.c_str());

  }else{
    dPrint(1,"Failed to get service information..");
    exit(1);
  }
  dPrint(1,"***************************************************************************************");

  std::list<gim::time> times;
  if(reader.GetTimes(times)){
    dPrint(1,"Got times... number of times %d",times.size());
  }else{
    dPrint(1,"Failed to get times ");
    exit(1);
  }

 dPrint(1,"***************************************************************************************");

 unsigned int imagecount = reader.GetImageCountPerPacket();

 dPrint(1,"Data packets contains %d images per packet",imagecount);

 dPrint(1,"***************************************************************************************");

 MaCI::Image::CImageData data;
 std::list<gim::time>::iterator iterFirst= times.begin();

 if(reader.GetImageData(data,
                        *iterFirst)){
   dPrint(1,"Got image data. Contains %d image",data.GetImageCount());
   for(int i = 0; i< data.GetImageCount();i++){
      MaCI::Image::CImageContainer imageContainer;
      MaCI::Image::TImageDataIterator *imageIteratorPtr = NULL;
     bool b = data.GetImage(imageContainer,imageIteratorPtr,false);
     dPrint(1,"b = %d",b);
     
   }

 }else{
   dPrint(1,"Failed to get first image..");
 }

}
